package com.lq.educationsystem.lqsubject.controller;

import com.lq.educationsystem.common.util.PageUtil;
import com.lq.educationsystem.common.util.Result;
import com.lq.educationsystem.common.util.ResultBuild;
import com.lq.educationsystem.common.util.ResultPage;
import com.lq.educationsystem.common.vo.TeacherSubjectPageVo;
import com.lq.educationsystem.lqsubject.entiy.TeacherSubjectTb;
import com.lq.educationsystem.lqsubject.service.SubjectBaseService;
import com.lq.educationsystem.lqsubject.service.SubjectTeacherBaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "教师课程信息")
@RestController
@RequestMapping("/subject/teacher/base")
public class SubjectTeacherBaseController {

    @Autowired
    SubjectTeacherBaseService subjectTeacherBaseService;
    //一些增删改查的方法

    //插入数据
    @Operation(summary = "插入教师课程信息")
    @PostMapping("/insert")
    public Result addInfo(@RequestBody TeacherSubjectTb teacherSubjectTb){
        subjectTeacherBaseService.insertInfo(teacherSubjectTb);

        return ResultBuild.buildOk();

    }

    //修改数据
    @Operation(summary = "修改教师课程信息")
    @PostMapping("/update")
    public Result updateInfo(@RequestBody TeacherSubjectTb teacherSubjectTb){

        subjectTeacherBaseService.updateInfo(teacherSubjectTb);
        return ResultBuild.buildOk();
    }

    //删除数据
    @Operation(summary = "删除教师课程信息")
    @PostMapping("/delete")
    public Result deleteInfo(@RequestBody TeacherSubjectTb teacherSubjectTb){

        //删除数据
        subjectTeacherBaseService.deleteInfo(teacherSubjectTb);
        return ResultBuild.buildOk();
    }

    //查询数据
    @Operation(summary = "分页查询教师课程信息")
    @PostMapping("/query")
    public ResultPage<TeacherSubjectTb> queryListInfo(@RequestBody TeacherSubjectPageVo teacherSubjectPageVo){
        ResultPage<TeacherSubjectTb> result = subjectTeacherBaseService.queryList(teacherSubjectPageVo);
        return  result;
    }
    //批量查询数据通过teacherSubjectId
    @Operation(summary = "通过teacherSubjectId 批量查询教师课程信息")
    @PostMapping("/query/subject")
    public ResultPage<TeacherSubjectTb> queryTeacherSubjectInfoByTeacherSubjectId(@RequestBody List<Integer> teacherSUbjectInfoIdList){
        ResultPage<TeacherSubjectTb> result = subjectTeacherBaseService.queryTeacherSubjectInfoByTeacherSubjectId(teacherSUbjectInfoIdList);
        return  result;
    }
    /**
     * 通过教师课程id查询教师所授课程
     */

    @Operation(summary = "通过教师id批量查询教师信息")
    @PostMapping("/query/teacher")
    public ResultPage<TeacherSubjectTb> queryTeacherSubjectInfoByTeacherId(@RequestBody Integer teacherId){

        ResultPage<TeacherSubjectTb> subjectTbResultPage = subjectTeacherBaseService.queryTeacherSubjectInfoByTeacherId(teacherId);
        return subjectTbResultPage;
    }



}
